/*
 * @Author: xiangxiaojun
 * @Date: 2022-05-11 09:03:45
 * @Descripttion: 关于信息
 */
import React, { useState, useEffect } from 'react';
import { Form, Modal } from 'antd';
import 'react-image-crop/dist/ReactCrop.css';
import { getAboutInfo } from '../../services';
import './index.less';
import _ from 'lodash';

const prefixCls = 'inbiz-CompanyInfo';

export interface CompanyInfoProps {
  visible?: boolean;
  value?: string;
  className?: string;
  onCancel?: () => any; // 取消
  onSubmit?: () => any; // 提交保存
}

const CompanyInfo: React.FC<CompanyInfoProps> = (props) => {
  const [form] = Form.useForm();
  const [data, $setData] = useState(null);

  const { visible, onCancel, onSubmit } = props;

  useEffect(() => {
    getAboutInfoFn();
  }, []);

  // 获取公司信息
  const getAboutInfoFn = async () => {
    const result = await getAboutInfo();
    $setData(result.data);
  };

  const ContentView = () => {
    return (
      <div className={`${prefixCls}`}>
        <div className={`${prefixCls}-logoBox`}>
          {_.get(data, 'ProductLogo') ? <img src={_.get(data, 'ProductLogo')} /> : null}
        </div>
        <div className={`${prefixCls}-textBox`}>
          <div className={`${prefixCls}-textBoxTop`}>
            <div className={`${prefixCls}-w`}>
              <div className={`${prefixCls}-icon`}></div>
              <div className={`${prefixCls}-text`}>{_.get(data, 'WarningText')}</div>
            </div>
            <div className={`${prefixCls}-ul`}>
              <div className={`${prefixCls}-li`}>ECM版本号：{_.get(data, 'LtlVersion')}</div>
              <div className={`${prefixCls}-li`}>产品序列号：{_.get(data, 'LtlSn')}</div>
              <div className={`${prefixCls}-li`}>授权：{_.get(data, 'LtlVersion')}</div>
            </div>
          </div>
          <div className={`${prefixCls}-copyright`}>
            <div>
              <span>Powered by</span>{' '}
              <span>
                <a href="http://www.macrowing.com" target="_blank">
                  edoc2 ECM
                </a>
              </span>
            </div>
            <div>© Macrowing Software Technology Co.,Ltd.</div>
          </div>
        </div>
      </div>
    );
  };

  return (
    <Modal
      footer={null}
      title={`关于`}
      visible={visible}
      width={620}
      onOk={onSubmit}
      onCancel={onCancel}
      bodyStyle={{ padding: `0 40px 0px 40px` }}
      wrapClassName={`${prefixCls}-modal`}
    >
      {ContentView()}
    </Modal>
  );
};

export default CompanyInfo;
